/**
 * 
 */
package com.skood.platform.webapp.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.skood.common.domain.EntityBean;
import com.skood.common.model.SearchModel;
import com.skood.platform.utils.WebUtils;

/**
 * @author keege
 * @date 2013-11-3
 * 所有Action的基类
 */
public class BaseAction<T extends SearchModel<E>,E extends EntityBean> extends ActionSupport{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	protected T searchModel;
	protected E entityBean;
	/********************************
	 * logic method
	 ********************************/
	protected HttpSession session(){
		return request().getSession();
	}
	protected HttpServletResponse response(){
		return ServletActionContext.getResponse();
	}
	protected HttpServletRequest request(){
		return ServletActionContext.getRequest();
	}
	protected void writeJson(Object result)throws Exception{
		WebUtils.writeJson(response(), result);
	}
	/*********************************
	 * getter and setter method
	 * ******************************/
	public T getSearchModel() {
		return searchModel;
	}
	
	public void setSearchModel(T searchModel) {
		this.searchModel = searchModel;
	}
	public E getEntityBean() {
		return entityBean;
	}
	public void setEntityBean(E entityBean) {
		this.entityBean = entityBean;
	}
	
}
